package com.javasm.controller.B2CController;

import com.javasm.common.http.AxiosResult;
import com.javasm.controller.base.BaseController;
import com.javasm.domin.criteria.orderCriteria.OrderReceiveCriteria;
import com.javasm.domin.entity.orderEntity.B2cReceiver;
import com.javasm.mapper.B2cOrderMapper.B2cReceiverMapper;
import com.javasm.service.B2cOrderService.B2cReceiverService;
import jdk.internal.org.objectweb.asm.tree.FieldInsnNode;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * @Author：liyangsong
 * @Version：1.0
 * @Date：2021/11/22-16:56
 * @Since:jdk1.8
 * @Description:
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/receive")
public class OrderReceiveController extends BaseController {

    private final B2cReceiverService b2cReceiverService;
    private final B2cReceiverMapper b2cReceiverMapper;

    @RequestMapping("/list")
    public AxiosResult<List<B2cReceiver>> show(){
        List<B2cReceiver> list = b2cReceiverService.list();
        return AxiosResult.success(list);
    }

    @RequestMapping("/man/{orderId}")
    public AxiosResult<B2cReceiver> find(@PathVariable Serializable orderId) {
        B2cReceiver receiverByOrderId = b2cReceiverMapper.findReceiverByOrderId(orderId);
//        B2cReceiver b2cReceiver = b2cReceiverMapper.selectById(orderId);
//        B2cReceiver byOrderId = b2cReceiverService.findByOrderId(orderReceiveCriteria);
        return AxiosResult.success(receiverByOrderId);
    }

    @RequestMapping("/add")
    public AxiosResult<Integer> add(@RequestBody B2cReceiver b2cReceiver){
        int insert = b2cReceiverMapper.insert(b2cReceiver);
        return AxiosResult.success(insert);
    }
}
